import {ActionType, PageContainer, ProColumns, ProTable} from "@ant-design/pro-components";
import React, {useRef} from "react";
import {globalLoadTableApi} from "@/services/admin-api/globalApi";

type WorkerEquipment = {
  workerEquipmentId: number;
  workerId: number;
  workerName: string;
  deviceBrand: string;
  deviceId: string;
  deviceModel: string;
  deviceType: string;
  system: string;
  platform: string;
  deviceCid: string;
  applyVersion: string;
  locationAuth: boolean;
  cameraAuth: boolean;
  photoAuth: boolean;
  delFlag: boolean;
  createTime: string;
  createUserId: number;
  createUserName: string;
  updateTime: string;
  updateUserId: number;
  updateUserName: string;
};

// const appType = [{label: 'android', value: 0}, {label: 'ios', value: 1}]

export default () => {

  const actionRef = useRef<ActionType>();

  const columns: ProColumns<WorkerEquipment>[] = [
    {title: '记录ID', dataIndex: 'workerEquipmentId', valueType: 'digit'},
    {title: '服务人员ID', dataIndex: 'workerId', valueType: 'digit', hideInSearch: true},
    {title: '服务人员', dataIndex: 'workerName', valueType: 'text', hideInSearch: true},
    {title: '品牌', dataIndex: 'deviceBrand', valueType: 'text', hideInSearch: true},
    {title: '设备ID', dataIndex: 'deviceId', valueType: 'text', hideInSearch: true},
    {title: '型号', dataIndex: 'deviceModel', valueType: 'text', hideInSearch: true},
    {title: '平台类型', dataIndex: 'deviceType', valueType: 'text', hideInSearch: true},
    {title: '系统', dataIndex: 'system', valueType: 'text', hideInSearch: true},
    {title: '平台', dataIndex: 'platform', valueType: 'text', hideInSearch: true},
    {title: '设备Cid', dataIndex: 'deviceCid', valueType: 'text', hideInSearch: true},
    {title: '应用版本', dataIndex: 'applyVersion', valueType: 'text', hideInSearch: true},
    {
      title: '位置权限',
      dataIndex: 'locationAuth',
      valueType: 'text',
      hideInSearch: true,
      render: (_, record) => record.locationAuth ? record.locationAuth.toString() : "false"
    },
    {
      title: '相机权限',
      dataIndex: 'cameraAuth',
      valueType: 'text',
      hideInSearch: true,
      render: (_, record) => record.cameraAuth ? record.cameraAuth.toString() : "false"
    },
    {
      title: '相册权限',
      dataIndex: 'photoAuth',
      valueType: 'text',
      hideInSearch: true,
      render: (_, record) => record.photoAuth ? record.photoAuth.toString() : "false"
    },
    {title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', hideInSearch: true,},
    {title: '创建用户ID', dataIndex: 'createUserId', valueType: 'digit', hideInSearch: true,},
    {title: '创建用户', dataIndex: 'createUserName', valueType: 'text', hideInSearch: true,},
    {title: '更新时间', dataIndex: 'updateTime', valueType: 'dateTime', hideInSearch: true,},
    {title: '更新用户ID', dataIndex: 'updateUserId', valueType: 'digit', hideInSearch: true,},
    {title: '更新用户', dataIndex: 'updateUserName', valueType: 'text', hideInSearch: true,},
  ];


  return <PageContainer header={{title: '', breadcrumb: {},}}>
    <ProTable<WorkerEquipment>
      columns={columns} actionRef={actionRef}
      search={{span: 4}}
      request={async (param) => globalLoadTableApi('/sys/equipment/table', param)}
      rowKey={(record) => record.workerEquipmentId}
      columnsState={{
        defaultValue: {
          delFlag: {show: false},
          createUserId: {show: false},
          updateUserId: {show: false}
        }
      }}/>

  </PageContainer>
}
